package com.cn.intelligence.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
/**
 * 订单管理
 * @author Administrator
 *
 */
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.intelligence.mapper.TbOrderMapper;
import com.cn.intelligence.pojo.EUDataGridResult;
import com.cn.intelligence.pojo.TaotaoResult;
import com.cn.intelligence.pojo.TbMUser;
import com.cn.intelligence.pojo.TbOrder;
import com.cn.intelligence.service.OrderService;
@Controller
@RequestMapping("/user/order")
public class OrderController {
	
	@Autowired
	OrderService orderService;
	@Autowired
	HttpServletRequest request;
	@Autowired
	public TbOrderMapper tbOrderMapper;
	
	/**
	 * 获取用户订单信息
	 */
    @RequestMapping("list")
    @ResponseBody
    public EUDataGridResult getSystemUserList(Integer page,Integer rows,TbOrder params,String sfd,String etd){
    	EUDataGridResult euDataGridResult = new EUDataGridResult();
    	TbMUser user = (TbMUser)request.getSession().getAttribute("user");
    	euDataGridResult =orderService.getOrders(page,rows,params,sfd,etd,user);

        return euDataGridResult;
    	  
         
    }
	/**
	 * 获取用户订单信息
	 */
	@RequestMapping("/userAddress/{addressId}")
	@ResponseBody
	public TaotaoResult selectuserAddress(@PathVariable Integer addressId){
		return orderService.selectuserAddress(addressId);
	}
	/**
	 * 获取用户订单信息
	 */
	@RequestMapping("/cartInfo/{cartId}")
	@ResponseBody
	public TaotaoResult cartInfo(@PathVariable Long cartId){
		return orderService.selectCartInfo(cartId);
	}
	/**
	 * 退货给客户
	 * @throws Exception 
	 */
	@RequestMapping(value="backproduct",method=RequestMethod.POST)
	@ResponseBody
	public TaotaoResult backproduct(String ids[]) throws Exception{
		return TaotaoResult.ok(orderService.updateOrderStatus(ids));
	}
	/**
	 * 获取所有发货员
	 * @throws Exception 
	 */
	@RequestMapping(value="getAllSender",method=RequestMethod.GET)
	@ResponseBody
	public List<TbMUser> getAllSender() throws Exception{
		return orderService.getAllSender();
	}
	
	
}
